<template>
  <view class="promotion-container">

    <!-- 顶部标题栏 -->
    <view class="header">
      <view class="back-btn" @click="goBack">
        <text class="back-arrow">←</text>
      </view>
      <text class="title">推广中心</text>
    </view>
    
    <!-- 余额信息 -->
    <view class="balance-card">
      <text class="balance-label">账户余额(元)</text>
      <text class="balance-amount">{{ userInfo.balance }}</text>
      <!-- <view class="balance-stats">
        <text class="stat-text">已提现 0</text>
        <text class="stat-divider">|</text>
        <text class="stat-text">提现中 0</text>
      </view> -->
    </view>
    
    <!-- 操作按钮 -->
    <view class="action-buttons">
      <button class="withdraw-button" @click="goToWithdrawal">提现</button>
    </view>
    
    <!-- 功能选项 -->
    <view class="options-section">
      
      <view class="option-item" @click="goToMyShareList">
        <view class="option-left">
          <text class="option-text">我的分享列表</text>
        </view>
        <text class="arrow-icon">></text>
      </view>

      <view class="option-item" @click="goToCashList">
        <view class="option-left">
          <text class="option-text">提现列表</text>
        </view>
        <text class="arrow-icon">></text>
      </view>
      
      <view class="option-item" @click="goToCommissionList">
        <view class="option-left">
          <text class="option-text">收益佣金列表</text>
        </view>
        <text class="arrow-icon">></text>
      </view>
    </view>
    
    
  </view>
</template>

<script>
// 移除未使用的API_CONFIG导入
export default {
  data() {
    return {
      userInfo:uni.getStorageSync('userInfo'),
      balance: '3151.43',
      withdrawnAmount: 0,
      withdrawingAmount: 0
    }
  },
  
  onLoad() {
    // 页面加载时获取余额信息
    this.getBalanceInfo()
  },
  
  methods: {
    // 返回上一页
    goBack() {
      uni.navigateBack()
    },
    // 获取余额信息
    async getBalanceInfo() {
      try {
        const token = uni.getStorageSync('token')
        if (!token) {
          uni.showToast({
            title: '请先登录',
            icon: 'none'
          })
          return
        }
        
        // 这里可以添加实际的API调用
        /*
        const res = await uni.request({
          url: API_CONFIG.BASE_URL + '/api/promotion/balance',
          method: 'GET',
          header: {
            'Content-Type': 'application/json',
            'Authorization': `Bearer ${token}`
          }
        })
        
        if (res.data.code === 0 && res.data.data) {
          this.balance = res.data.data.balance || '0'
          this.withdrawnAmount = res.data.data.withdrawnAmount || 0
          this.withdrawingAmount = res.data.data.withdrawingAmount || 0
        }
        */
        
        // 模拟数据已在模板中硬编码
        
      } catch (error) {
        uni.showToast({
          title: '获取余额信息失败',
          icon: 'none'
        })
        console.error('获取余额信息失败:', error)
      }
    },
    
    // 跳转到提现页面
    goToWithdrawal() {
      uni.navigateTo({
        url: '/pages/withdrawal/withdrawal'
      })
    },
    
    
    // 跳转到我的分享列表页面
    goToMyShareList() {
      uni.navigateTo({
        url: '/pages/share-list/share-list'
      })
    },
    
    // 跳转到提现列表页面
    goToCashList() {
      uni.navigateTo({
        url: '/pages/cash-list/cash-list'
      })
    },
    
    // 跳转到收益佣金列表页面
    goToCommissionList() {
      uni.navigateTo({
        url: '/pages/commission-list/commission-list'
      })
    },
  }
}
</script>

<style scoped>
.promotion-container {
  background-color: #3A3052;
  min-height: 100vh;
  padding-bottom: 120rpx;
}

.header {
  background-color: #4A4062;
  padding: 10px 65px 10px 15px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.back-btn {
  width: 40px;
  height: 40px;
  background-color: rgba(240, 217, 181, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.back-btn:active {
  background-color: rgba(240, 217, 181, 0.2);
  transform: scale(0.95);
}

.back-arrow {
  color: #F0D9B5;
  font-size: 22px;
  font-weight: bold;
}

.title {
  flex: 1;
  color: rgba(255, 255, 255, 0.5);
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}


.balance-card {
  background-color: #F8E7D0;
  border-radius: 16rpx;
  padding: 30rpx;
  margin: 20rpx;
  text-align: center;
}

.balance-label {
  color: #3A3052;
  font-size: 32rpx;
  display: block;
  margin-bottom: 10rpx;
}

.balance-amount {
  color: #3A3052;
  font-size: 48rpx;
  font-weight: bold;
  display: block;
  margin-bottom: 15rpx;
}

.balance-stats {
  display: flex;
  justify-content: center;
  align-items: center;
}

.stat-text {
  color: #8F82A8;
  font-size: 28rpx;
}

.stat-divider {
  color: #8F82A8;
  font-size: 28rpx;
  margin: 0 15rpx;
}

.action-buttons {
  display: flex;
  padding: 0 20rpx 20rpx;
  gap: 20rpx;
}

.withdraw-button {
  flex: 1;
  background-color: #F44336;
  color: #FFFFFF;
  font-size: 36rpx;
  font-weight: bold;
  padding: 25rpx;
  border-radius: 16rpx;
  border: none;
}

.recharge-button {
  flex: 1;
  background-color: #F44336;
  color: #FFFFFF;
  font-size: 36rpx;
  font-weight: bold;
  padding: 25rpx;
  border-radius: 16rpx;
  border: none;
}

.withdraw-button:active,
.recharge-button:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.options-section {
  background-color: #4A4062;
  border-radius: 16rpx;
  margin: 0 20rpx 20rpx;
  overflow: hidden;
}

.option-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 25rpx 30rpx;
  border-bottom: 1rpx solid #52496D;
}

.option-item:last-child {
  border-bottom: none;
}

.option-left {
  display: flex;
  align-items: center;
}

.option-icon {
  width: 40rpx;
  height: 40rpx;
  margin-right: 20rpx;
}

.option-icon image {
  width: 100%;
  height: 100%;
}

.option-text {
  color: #FFFFFF;
  font-size: 32rpx;
}

.arrow-icon {
  color: #8F82A8;
  font-size: 32rpx;
}

.data-section {
  padding: 0 20rpx 20rpx;
}

.data-title {
  color: #FFFFFF;
  font-size: 32rpx;
  font-weight: bold;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120rpx;
  background-color: #2A2240;
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-top: 1rpx solid #3A3052;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #8F82A8;
}

.nav-item.active {
  color: #F0D9B5;
}

.nav-item image {
  width: 50rpx;
  height: 50rpx;
  margin-bottom: 10rpx;
}

.nav-item text {
  font-size: 24rpx;
}
</style>